package com.company.design.create.singleton.normal;

/**
 * @author yingfing
 * @create 2020--09--26 16:36
 * @describe 普通单例模式 - 懒汉
 */
public class Singleton {
    // 1.私有化静态实例,防止被引用,懒加载
    private static Singleton instance = null;

    // 2.私有化构造方法
    private Singleton() {
    }

    // 3.静态方法,创建实例
    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}
